import { DiagramCustomizationManagementModel } from "../../DiagramCustomizationManagementModel";

export const thumbnailTableData = [
  {
    enName: "image",
    enTips:
      "The image acts like stereotype image, overriding any other images. Regular stereotype symbol properties will be working, even if no stereotype is assigned.",
    key: "DiagramThumbnail",
    name: "图片",
    value: null
  },
  {
    enName: "Name",
    enTips: "The name of the NamedElement.",
    key: "DiagramDesc",
    name: "视图描述",
    value: ""
  }
];

export class ThumbnailModel {
  thumbnailInfo: any[] = [];

  constructor(public diagramCustomizationManagementModel: DiagramCustomizationManagementModel) {
    /*   this.stereotypeModelId = query.stereotypeModelId;
    this.constraintModelId = query.constraintModelId; */
  }

  initThumbnailData(thumbnailInfo) {
    if (thumbnailInfo) {
      thumbnailTableData.forEach(item => {
        if (item.key === "DiagramThumbnail") {
          item.value = thumbnailInfo.img;
        } else if (item.key === "DiagramDesc") {
          item.value = thumbnailInfo.description;
        }
      });
      this.thumbnailInfo = thumbnailTableData;
    } else {
      this.thumbnailInfo = thumbnailTableData;
    }
  }

  // 选择图片 || 更改视图描述
  updateValue(val: string, key: string) {
    this.thumbnailInfo.find(item => item.key === key).value = val;
  }
}
